#!/usr/bin/env python3

import ctypes
import sys

import component.middleware.util.binio as middleware__util__binio
import component.middleware.util.binio_test as middleware__util__binio_test


def test():
    test_struct = middleware__util__binio_test.binio.TestStruct(
        n=3, tag='test')
    print(test_struct.n.GetValue())
    # print(test_struct.tag.GetValue())

    buf = ctypes.create_string_buffer(
        b'\x04\x00\x00\x00\x00\x00\x00\x00abcd................')
    cbuf = middleware__util__binio.binio.CBuffer(ctypes.addressof(buf))
    print(f'{cbuf.data_len()}: [{str(cbuf)}]')
    i = middleware__util__binio.binio.CInt32(0x44434241)
    i.WriteBuf(ctypes.addressof(buf))
    print(f'{cbuf.data_len()}: [{str(cbuf)}]')
    print(f'{i.ReadBuf(ctypes.addressof(buf), 4)}')
    return 0


if __name__ == '__main__':
    sys.exit(test())
